<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/public/inc/tags.jsp"%>
<input type="hidden" value="${model.id}" name="id">
<div class="form-horizontal">
    <div class="form-group">
        <label class="control-label col-md-2">名称</label>
        <div class="col-md-3">
            <input type="text" id="name" name="name" class="form-control" placeholder="请输入名称"
                   value="${model.name}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">优惠面额</label>
        <div class="col-md-3">
            <input type="text" id="price" name="price" class="form-control" placeholder="请输入面额"
                   value="${model.price}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">使用条件</label>
        <div class="col-md-3">
            <input type="text" id="priceSub" name="priceSub" class="form-control" placeholder="请输入使用条件"
                   value="${model.priceSub}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">是否启用</label>
        <div class="col-md-3">
            <label>
                <select name="status" id="status" class="form-control">
                    <option value="">请选择</option>
                    <option value="0" <c:if test="${model.status==0}"> selected="selected"</c:if>>是</option>
                    <option value="1" <c:if test="${model.status==1}"> selected="selected"</c:if>>否</option>
                </select>
            </label>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">有效期</label>
        <div class="col-md-3">
            <fmt:formatDate value="${model.effective}" var="time"/>
            <input class="form-control date-picker" readonly="readonly" id="effective" name="effective" value="${time}" placeholder="格式:2000-08-08" />
        </div>
        <div class="col-md-3">
            <fmt:formatDate value="${model.expires}" var="time"/>
            <input class="form-control date-picker" readonly="readonly" id="expires" name="expires" value="${time}" placeholder="格式:2000-08-08" />
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">数量</label>
        <div class="col-md-3">
            <input type="text" id="num" name="num" class="form-control" placeholder="请输入使用数量"
                   value="${model.num}"/>
        </div>
    </div>
</div>

<div class="form-group">
    <div class="col-md-offset-2 col-md-2">
        <button type="submit" class="btn btn-primary">
            <i class="fa fa-floppy-o"></i> 保存
        </button>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {

        $("#form1").bootstrapValidator({
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                name: {
                    validators: {
                        notEmpty: {
                            message: '不能为空'
                        }
                    }
                }, price: {
                    validators: {
                        notEmpty: {
                            message: '不能为空'
                        },regexp: {
                            regexp: /^[0-9]+([.]{1}[0-9]+){0,1}$/,
                            message: '整数或小数'
                        }
                    }
                }, priceSub: {
                    validators: {
                        notEmpty: {
                            message: '不能为空'
                        },regexp: {
                            regexp: /^[0-9]+([.]{1}[0-9]+){0,1}$/,
                            message: '整数或小数'
                        }
                    }
                }, status: {
                    validators: {
                        notEmpty: {
                            message: '不能为空'
                        }, regexp: {
                            regexp: /^[0-1]*$/,
                            message: '必须选择其中的一个'
                        }
                    }
                }, effective: {
                    validators: {
                        notEmpty: {
                            message: '不能为空'
                        }
                    }
                }, expries: {
                    validators: {
                        notEmpty: {
                            message: '不能为空'
                        }
                    }
                }
            }
        });
    });
</script>